package e.odbo.data;

import com.openbravo.data.loader.serialize.Datas;
import com.openbravo.data.loader.serialize.serializer.SerializerRead;
import com.openbravo.data.loader.serialize.serializer.SerializerWrite;
import com.openbravo.data.loader.serialize.serializer.read.*;
import com.openbravo.data.loader.serialize.serializer.write.*;
import e.odbo.data.bean.key.KeyBuilder;
import e.odbo.data.format.Formats;
import e.odbo.data.generator.*;

import java.util.Date;
import java.util.regex.Pattern;

public class OdbO {
    public static final class READER{
      public static final SerializerRead<Integer> INT = SerializerReadInteger.INSTANCE;

      public static final SerializerRead<Byte[]> BYTES= SerializerReadBytes.INSTANCE;

      public static SerializerRead<Double> DOUBLE= SerializerReadDouble.INSTANCE;

      public static SerializerRead<String> STRING= SerializerReadString.INSTANCE;

      public static SerializerRead UTF8= SerializerReadImage.INSTANCE;

      public static SerializerRead Serializer(Class t){
          return new SerializerReadClass(t);
      }

      public static SerializerRead DATAS(Datas... datas){
          return new SerializerReadDatas(datas);
      }
    }

    public static class WRITER{
        public static SerializerWrite INT= SerializerWriteInteger.INSTANCE;

        public static SerializerWrite LONG= SerializerWriteLong.INSTANCE;

        public static SerializerWrite STRING= SerializerWriteString.INSTANCE;

        public static SerializerWrite DATAS(Datas... datas){
            return new SerializerWriteBasic(datas);
        }

        public static SerializerWrite PARAMS= SerializerWriteParams.INSTANCE;
    }

    public static abstract class DATAS extends Datas{}

    public static abstract class FORMATS extends Formats {}

    public static class ID extends KeyBuilder{}

    public static class PATTERN{
        public static Pattern VER_3_2_1_Pattern=Pattern.compile("^([1-9]\\d|[1-9])(\\.([1-9]\\d|\\d)){2}$");

        public static Pattern VER_2018_08_01_Pattern=Pattern.compile("((\\d{2}(([02468][048])|([13579][26]))[\\-]((((0?[13578])|(1[02]))[\\-]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-]((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-]((((0?[13578])|(1[02]))[\\-]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-]((0?[1-9])|(1[0-9])|(2[0-8]))))))");


        /*
        "^\\d+$"　　//非负整数（正整数   +   0）
        "^[0-9]*[1-9][0-9]*$"　　//正整数
        "^((-\\d+)|(0+))$"　　//非正整数（负整数   +   0）
        "^-[0-9]*[1-9][0-9]*$"　　//负整数
        "^-?\\d+$"　　　　//整数
        "^\\d+(\\.\\d+)?$"　　//非负浮点数（正浮点数   +   0）
        "^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"　　//正浮点数
        "^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$"　　//非正浮点数（负浮点数   +   0）
        "^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"　　//负浮点数
        "^(-?\\d+)(\\.\\d+)?$"　　//浮点数
         车牌:carRegex "^[\u4e00-\u9fa5]{1}[a-zA-Z]{1}[a-zA-Z_0-9]{4}[a-zA-Z_0-9_\u4e00-\u9fa5]$"

         */
    }

    public static abstract class GENERATOR extends Generator {

        public static final class EMAIL{
            public static EmailGenerator generator(){
                return new EmailGenerator();
            }
        }

        public static final class PASSWORD{
            public static PasswordGenerator generator(int lineLength){ return new PasswordGenerator(lineLength);}

            public static PasswordGenerator generator(int lineLength,boolean symbol){ return new PasswordGenerator(lineLength,symbol);}

            public static PasswordGenerator generator(int lineLength,String extStr,boolean symbol){ return new PasswordGenerator(lineLength,extStr,symbol);}
        }

        public static final class RANDOM_DATE{
            public static RandomDateGenerator generator(){return new RandomDateGenerator();}

            public static RandomDateGenerator generator(Date start){return new RandomDateGenerator(start);}

            public static RandomDateGenerator generator(Date start, Date end){return new RandomDateGenerator(start,end);}
        }

        public static final class TELEPHONE{
            public static TelephoneGenerator generator(){
                return new TelephoneGenerator();
            }
        }

        public static final class ROUND_STRING{
            public static RoundStringGenerator generator(int lineLength){
                return new RoundStringGenerator(lineLength);
            }

            public static RoundStringGenerator generator(int lineLength,boolean symbol){
                return new RoundStringGenerator(lineLength,symbol);
            }

            public static RoundStringGenerator generator(int lineLength,String advString,boolean symbol){
                return new RoundStringGenerator(lineLength,advString,symbol);
            }
        }


        public static final class CARD_NUMBER{
            public static CardNumberGenerator generator(String prefix, int length){
                return new CardNumberGenerator(prefix,length);
            }

            public static CardNumberGenerator generator(String[] prefix, int length){
                return new CardNumberGenerator(prefix,length);
            }
        }
    }

}
